package org.smr.ministore.service.impl;

import java.util.List;

import org.blade.dao.base.BaseMapper;
import org.blade.utils.IdGenUtils;
import org.blade.utils.Pager;
import org.blade.service.base.AbstractService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smr.ministore.dao.GoodsTypeOrganMapper;
import org.smr.ministore.entities.GoodsTypeOrgan;
import org.smr.ministore.entities.vo.GoodsTypeOrganQuery;
import org.smr.ministore.service.GoodsTypeOrganService;

import org.springframework.beans.factory.annotation.Autowired;


import org.springframework.stereotype.Service;

@Service("GoodsTypeOrganService")
public class GoodsTypeOrganServiceImpl extends AbstractService<Long, GoodsTypeOrgan> implements GoodsTypeOrganService {


    private static Logger logger = LoggerFactory.getLogger(GoodsTypeOrganServiceImpl.class);


	@Autowired
	private GoodsTypeOrganMapper mapper;

	@Autowired
	public GoodsTypeOrganServiceImpl(BaseMapper<Long, GoodsTypeOrgan> mapper) {
		super(mapper);
	}

	public int save(GoodsTypeOrgan entity) {
		super.saveAttatch(entity);

		return mapper.insert(entity);
	}

	public int updateById(GoodsTypeOrgan id) {
		super.modifyAttach(id);

		return mapper.updateById(id);
	}

	public GoodsTypeOrgan queryById(Long id) {
		return mapper.selectById(id);
	}

	public int deleteById(Long id) {
		return mapper.deleteById(id);
	}

	public Pager<GoodsTypeOrgan> paginate( GoodsTypeOrgan entity, Long pageSize, Long pageNum) {

		Pager<GoodsTypeOrgan> pager = new Pager( pageSize, pageNum );
		List list  = mapper.pagination(entity, pager);
		pager.setEntities(list);
		return pager;
    }
	
	public int batchSave(List<GoodsTypeOrgan> entities) {
        this.batchSaveAttatch(entities);
		return mapper.batchInsert(entities);
	}


    public int batchModify(List<GoodsTypeOrgan> entities) {
        this.batchModifyAttatch(entities);
        return mapper.batchUpdate(entities);
	}


    public int deleteByIdLogical(Long id) {
        return mapper.deleteByIdLogical(id);
    }


	public List<GoodsTypeOrgan> queryAlreadyAssignedOrgans(GoodsTypeOrganQuery goodsTypeOrganQuery) {

		return mapper.queryAlreadyAssignedOrgans(goodsTypeOrganQuery);
	}

	public Long getId() {
		return IdGenUtils.getNextLongId();
	}
}
